import request from "@/utils/request";
import {
  LoginData,
  LoginResult,
  InitMenusResult,
  CaptchaResult,
} from "./types";
import { AxiosPromise } from "axios";

/**
 * 登录
 * @param data
 * @returns
 */
function loginApi(data: LoginData): AxiosPromise {
  return request({
    url: "/lejuAdmin/index/login",
    method: "post",
    data,
  });
}

/**
 * 获取初始化用户菜单及权限
 * @returns
 */
function getInitMenus(): AxiosPromise<InitMenusResult> {
  return request({
    url: "/admin/sysAuth/index/getInitMenus",
    method: "get",
  });
}

/**
 * 获取验证码
 */
export function getCaptchaApi(): AxiosPromise<CaptchaResult> {
  return request({
    url: "/api/v1/auth/captcha",
    method: "get",
  });
}

export { loginApi, getInitMenus };
